package info.itloser.learnkotlindemo.adapter

import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager2.adapter.FragmentStateAdapter
import info.itloser.learnkotlindemo.MainActivity

/**
 * Created by itloser.info
 * on 2021/6/10
 */
class MainFragmentsAdapter(mainActivity: MainActivity, fragments: List<Fragment>) :
    FragmentStateAdapter(mainActivity) {

    var fragments: List<Fragment>? = null

    init {
        this.fragments = fragments
    }


    override fun getItemCount(): Int {
        return fragments!!.size
    }

    override fun createFragment(position: Int): Fragment {
        return fragments!![position]
    }

}